import cv2
import numpy as np
import os

def cropT(path):
    filename = os.path.basename(path)
    img = cv2.imread(path, cv2.IMREAD_COLOR)
    img = cv2.resize(img, (1280, 4210))   # w, h
    img_1 = img[(851 - 640):(851 + 640), :]
    img_2 = img[(3351 - 640):(3351 + 640), :]

    cv2.imwrite(os.path.join('data_out', filename.split('.')[0] + '_1' + '.jpg'), img_1)
    cv2.imwrite(os.path.join('data_out', filename.split('.')[0] + '_2' + '.jpg'), img_2)

if __name__ == "__main__":
    path = 'data'
    for file in os.listdir('data'):
        cropT(os.path.join(path, file))